package com.mzj.saas.task;

import com.haixiaoke.saas.repository.pojo.HousingAllocation;
import com.haixiaoke.saas.repository.service.impl.ApartmentBillServiceImpl;
import com.haixiaoke.saas.repository.service.impl.HouseKeeperServiceImpl;
import com.haixiaoke.saas.repository.service.impl.OrderContractServiceImpl;
import com.mzj.saas.mservice.property.service.CommunityHouseUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 公寓定时任务
 *
 * @author qixi
 * @date 2023/10/26
 */

@Component
public class ApartmentTask {

    @Autowired
    private ApartmentBillServiceImpl apartmentBillServiceImpl;

    @Autowired
    private HouseKeeperServiceImpl houseKeeperServiceImpl;

    @Autowired
    private OrderContractServiceImpl orderContractService;

    @Autowired
    private CommunityHouseUserService communityHouseUserService;

    @Scheduled(cron="0 0 0 * * ?")
    public void createApartmentBillTask() {
        apartmentBillServiceImpl.createApartmentBillTask();
    }

    @Scheduled(cron="12 0 0 * * ? ")
    public void surrenderRentTask() {
        houseKeeperServiceImpl.surrenderRentTask(HousingAllocation.APARTMENT_TYPE_LONG);
    }

    @Scheduled(cron="0 0 0 * * ? ")
    public void surrenderShortRentTask() {
        houseKeeperServiceImpl.surrenderRentTask(HousingAllocation.APARTMENT_TYPE_SHORT);
    }

    @Scheduled(cron="0 0 0 * * ? ")
    public void createBacklogItemOrderContractTask() {
        orderContractService.orderContractDeadlineTask();
    }

    @Scheduled(cron="0 0 0 * * ? ")
    public void openPushMessageTask() {
        communityHouseUserService.openPushMessageTask();
    }

}
